{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import keras\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "digits = keras.datasets.mnist\n",
    "(X_train, y_train), (X_test, y_test) = digits.load_data()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train = X_train/255\n",
    "X_test = X_test/255"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x1fda466ba90>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQQAAAECCAYAAAAYUakXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADzJJREFUeJzt3X2QVfV9x/HPB7KCIDhQIyFWS4kSSm0DdaOxMcHEiYN2\npupMQ8p0DLV2cCYJxWjbOE5ndNJpx2Z8yIMPKUYiNkrGGZ+YDjVFytSYKHFBKggaLYEKrlDBFh+R\nZb/9Y4+/bA37O7t7H85hfb9mmL17Ppc9X4/48Zx7f5zriBAASNKoqgcAUB8UAoCEQgCQUAgAEgoB\nQEIhAEgqKQTb82w/Z/sF21dVMUOO7e22N9neaLurBvMss73H9uZ+2ybbXm37+eLrpJrNd63tXcUx\n3Gj7/ArnO9H2WttbbD9je0mxvRbHMDNf24+h270OwfZoST+X9DlJOyU9KWlBRGxp6yAZtrdL6oyI\nV6qeRZJsf1rS65LuiohTi23fkLQvIq4rSnVSRHytRvNdK+n1iLi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IKEQACQUAoCEQgCQlBaC\n7RNtr7W9xfYztpcU26+1vcv2xuLX+a0fF0ArDeYGKT2SroyIDbYnSFpve3WR3RQR17duPADtVFoI\nEdEtqbt4/JrtrZJOaPVgANpvSK8h2J4maY6kdcWmxbaftr3M9qQmzwagzQZdCLaPkXSfpMsjYr+k\n2yRNlzRbfWcQNwzw+xbZ7rLddVAHmjAygFYZVCHY7lBfGdwdEfdLUkTsjohDEdEr6XZJpx/u90bE\n0ojojIjODo1p1twAWmAw7zJY0h2StkbEjf22T+33tIskbW7+eADaaTDvMnxS0sWSNtneWGy7WtIC\n27MlhaTtki5ryYQA2mYw7zI8Julwf496VfPHAVAlVioCSCgEAAmFACChEAAkFAKAhEIAkFAIABIK\nAUBCIQBIKAQACYUAIKEQACQUAoCEQgCQUAgAEkdE+3Zm/7ekHf02HSfplbYNMHTM15g6z1fn2aTm\nz/cbEfHBsie1tRB+Zed2V0R0VjZACeZrTJ3nq/NsUnXzcckAIKEQACRVF8LSivdfhvkaU+f56jyb\nVNF8lb6GAKBeqj5DAFAjFAKAhEIAkFAIABIKAUDyf/zrMqJGa9wyAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fda7e02908>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.matshow(X_train[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_train[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = keras.models.Sequential()\n",
    "model.add(keras.layers.Flatten(input_shape=[28, 28]))\n",
    "model.add(keras.layers.Dense(20, activation=\"relu\"))\n",
    "model.add(keras.layers.Dense(10, activation=\"softmax\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "flatten_1 (Flatten)          (None, 784)               0         \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 20)                15700     \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 10)                210       \n",
      "=================================================================\n",
      "Total params: 15,910\n",
      "Trainable params: 15,910\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model.compile(loss=\"sparse_categorical_crossentropy\", # sparse_categorical_crossentropy             \n",
    "              optimizer=\"adam\",\n",
    "              metrics=[\"accuracy\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/1\n",
      "60000/60000 [==============================] - 3s 49us/step - loss: 0.4085 - acc: 0.8858\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x1fd96b352b0>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10000/10000 [==============================] - 0s 29us/step\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[0.23919174144268035, 0.9337]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.evaluate(X_test, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x1fda59eafd0>"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQQAAAECCAYAAAAYUakXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADe5JREFUeJzt3X+sX/Vdx/HXa/T2st4W166j1vKj1rHFbo6S3MEW0HRB\nJttCgGzDNZHUZK5EkYBZVNJkgUSdSPghOiUpUtcthckGCNlwhjXTSsSOlpS2tCiIRVsvvUCnLQP6\ng779456+vWP3fr733u+Pcy59PpLm+/2e97nnvHt676ufc76f77mOCAGAJL2j7gYANAeBACARCAAS\ngQAgEQgAEoEAINUSCLYvtv2vtp+zfX0dPZTY3m17u+2ttjc3oJ+1todt7xi1bJ7tR20/Wz3ObVh/\nN9reWx3DrbY/WWN/p9v+vu2dtp+2fW21vBHHsNBfz4+hez0PwfZJkv5N0kWS9kh6QtKKiNjZ00YK\nbO+WNBgRL9fdiyTZ/iVJr0r6WkR8sFp2s6T9EXFTFapzI+L3G9TfjZJejYhb6uhpNNsLJS2MiCdt\nz5G0RdJlkn5dDTiGhf6uUI+PYR0jhHMlPRcRz0fEYUnfkHRpDX1MGxGxUdL+tyy+VNK66vk6jXwD\n1WKc/hojIoYi4snq+UFJuyQtUkOOYaG/nqsjEBZJ+q9Rr/eopr98QUj6nu0ttlfV3cw4FkTEUPX8\nRUkL6mxmHNfY3ladUtR2SjOa7cWSzpG0SQ08hm/pT+rxMeSi4tguiIhlkj4h6epqSNxYMXLe17Q5\n6HdKWiJpmaQhSbfW245ke7ak+yVdFxEHRteacAzH6K/nx7COQNgr6fRRr0+rljVGROytHoclPaiR\n05ym2Vedex4/Bx2uuZ8fExH7IuLNiDgm6S7VfAxt92nkh219RDxQLW7MMRyrvzqOYR2B8ISks2z/\nrO2Zkj4n6eEa+hiT7YHqwo5sD0j6uKQd5a+qxcOSVlbPV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AoBEIABILech2D5d0tckLZAUktZExB22b5T0BUkvVauujohHutUopP8+/6Ri/YwZ7c0zWH/w1GK9\n70D5fgjcDWH6m8jEpKOSvhgRT9qeI2mL7Uer2u0RcUv32gPQSy0DISKGJA1Vzw/a3iVpUbcbA9B7\nk7qGYHuxpHMkbaoWXWN7m+21tsv37wLQeBMOBNuzJd0v6bqIOCDpTklLJC3TyAhizIn0tlfZ3mx7\n8xEd6kDLALplQoFgu08jYbA+Ih6QpIjYFxFvRsQxSXdJGvOTNxGxJiIGI2KwT/2d6htAF7QMBNuW\ndLekXRFx26jlC0etdrmkHZ1vD0AvTeRdhvMlXSlpu+2t1bLVklbYXqaRd5t2S7qqKx0C6JmJvMvw\nmCSPUWLOwTTzx68sLdYf/5XFxXoMbe9gN2giZioCSAQCgEQgAEgEAoBEIABIBAKARCAASI7o3afY\nT/G8OM8X9mx/AEZsig06EPvHmk/0YxghAEgEAoBEIABIBAKARCAASAQCgEQgAEg9nYdg+yVJL4xa\nNF/Syz1rYPLorz1N7q/JvUmd7+/MiHhPq5V6Ggg/sXN7c0QM1tZAC/TXnib31+TepPr645QBQCIQ\nAKS6A2FNzftvhf7a0+T+mtybVFN/tV5DANAsdY8QADQIgQAgEQgAEoEAIBEIANL/ASZ61Xp0/62/\nAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fda4960be0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.matshow(X_test[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "yp = model.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([6.2274383e-05, 5.1421192e-09, 3.7618112e-04, 1.8699981e-03,\n",
       "       9.6290319e-07, 6.9304413e-05, 2.5942017e-08, 9.9744511e-01,\n",
       "       9.6367085e-06, 1.6648159e-04], dtype=float32)"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yp[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.argmax(yp[0])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
